package com.realgodo.site.web.user.space;

import java.util.List;

import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;

import com.realgodo.site.entity.space.SpaceCover;
import com.realgodo.site.service.space.SpaceCoverManager;
import com.realgodo.site.web.user.UserDefaultController;

@Scope("prototype")
@Results( { @Result(name = "toindex", type = "redirect", location = "${base}/user/") })
public class IndexController extends UserDefaultController {

	private static final long serialVersionUID = 9128737532321354660L;

	@Autowired
	private SpaceCoverManager spaceCoverManager;

	private List<SpaceCover> spaceCovers;
	private SpaceCover bean;
	private String notice;
	
	private String zoomPath;

	public String execute() throws Exception {
		notice = super.getSpace().getNotice();
		spaceCovers = this.spaceCoverManager.getSpaceCovers(super.getSpace()
				.getId(), SpaceCover.MAX_RUSULT);
		return SUCCESS;
	}

	public String save() throws Exception {
		if (null != bean) {
			this.spaceCoverManager.saveSpaceCover(super.getSpace(), bean);
		}
		return "toindex";
	}

	public String zoom() {
		return "zoom";
	}

	public List<SpaceCover> getSpaceCovers() {
		return spaceCovers;
	}

	public void setSpaceCovers(List<SpaceCover> spaceCovers) {
		this.spaceCovers = spaceCovers;
	}

	public String getNotice() {
		return notice;
	}

	public void setNotice(String notice) {
		this.notice = notice;
	}

	public SpaceCover getBean() {
		return bean;
	}

	public void setBean(SpaceCover bean) {
		this.bean = bean;
	}

	public String getZoomPath() {
		return zoomPath;
	}

	public void setZoomPath(String zoomPath) {
		this.zoomPath = zoomPath;
	}

	
}
